﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerBullet : MonoBehaviour
{
    //子弹移动速度
    private float bulletMoveSleep = 10;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        //子弹移动
        transform.Translate(transform.up * bulletMoveSleep * Time.deltaTime, Space.World);
    }

    private void OnTriggerEnter2D(Collider2D collider)
    {
        switch (collider.tag)
        {
            case "WallTag":
                //碰到墙壁
                //销毁墙
                Destroy(collider.gameObject);
                //销毁子弹自身
                Destroy(gameObject);
                break;
            case "EnemyTag":
                //碰到敌人
                collider.SendMessage("EnemyDie");
                break;
            case "TankTag":
                //玩家子弹碰到玩家
                break;
            case "BarrierTag":
                //碰到障碍物
                //销毁子弹自身
                Destroy(gameObject);
                break;
            case "EdgeTag":
                //子弹碰上边缘时
                Destroy(gameObject);
                break;
            case "BulletTag":
                //子弹对上子弹时
                Destroy(gameObject);
                break;
            case "HeartTag":
                //碰到心脏
                //调用心脏死亡方法
                collider.SendMessage("HeartDie");
                Destroy(gameObject);
                break;
            default:
                break;
        }

    }
}
